﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using IWshRuntimeLibrary;

namespace com.sanadc.shohdi.windowslink
{
    public class ShohdiWindowsLink
    {
        
        public static void createLink(string strFile, string strLinkDir, string strLinkName)
        {
            try
            {
                if (!strLinkDir.EndsWith("\\"))
                    strLinkDir += "\\";
                if (!Directory.Exists(strLinkDir))
                {
                    try { Directory.CreateDirectory(strLinkDir); }
                    catch { }
                }


                if (System.IO.File.Exists(strLinkDir + strLinkName + ".lnk"))
                {
                    try { System.IO.File.Delete(strLinkDir + strLinkName + ".lnk"); }
                    catch { }
                }

                WshShell Shell = new WshShell();
                IWshShortcut link = (IWshShortcut)Shell.CreateShortcut(strLinkDir + strLinkName + ".lnk");
                link.TargetPath = strFile;

                link.Save();
            }
            catch
            {
            }
            
            
        }
    }
}
